package com.bwie.service.impl;

import com.bwie.mapper.ReceiveMapper;
import com.bwie.mapper.ShipmentsMapper;
import com.bwie.pojo.*;
import com.bwie.service.OrderInfoService;
import com.bwie.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Title:
 * @BelongProjecet practice2
 * @BelongPackage com.bwie.service.impl
 * @Description:
 * @Copyright 研发一部
 * @Author: Mr.yan
 * @Date: 2024/6/7 15:11
 * @Version V1.0
 */
@Service
public class OrderInfoServiceImpl implements OrderInfoService {
    @Autowired
    private ShipmentsMapper shipmentsMapper;
    @Autowired
    private ReceiveMapper receiveMapper;

    @Override
    public R addShipments(TbOrder tbOrder) {
        TbShipments tbShipments = new TbShipments();
        tbShipments.setShipmentsName(tbOrder.getShipmentsName());
        tbShipments.setShipmentsTel(tbOrder.getShipmentsTel());
        tbShipments.setShipmentsAddress(tbOrder.getShipmentsAddress());
        tbShipments.setShipmentsDetails(tbOrder.getShipmentsDetails());
        shipmentsMapper.insert(tbShipments);
        return R.success(tbShipments.getId());
    }

    @Override
    public R addReceive(TbOrder tbOrder) {
        TbReceive tbReceive = new TbReceive();
        tbReceive.setReceiveName(tbOrder.getReceiveName());
        tbReceive.setReceiveTel(tbOrder.getReceiveTel());
        tbReceive.setReceiveAddress(tbOrder.getReceiveAddress());
        tbReceive.setReceiveDetails(tbOrder.getReceiveDetails());
        receiveMapper.insert(tbReceive);
        return R.success(tbReceive.getId());
    }

    @Override
    public R selectPay() {
        List<TbPay> payList = shipmentsMapper.payList();
        return R.success(payList);
    }

    @Override
    public R selectStatus() {
        List<TbStatus> statusList = shipmentsMapper.statusList();
        return R.success(statusList);
    }

    @Override
    public R goodsTypeList() {
        List<TbType> typeList = shipmentsMapper.typeList();
        return R.success(typeList);
    }
}
